unit Con_Layout;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls, DB,
  dbtables;

type
  TfrmCon_Layout = class(TForm)
    Label1_: TLabel;
    edtDescricao: TEdit;
    dbglayout: TDBGrid;
    GB_01: TGroupBox;
    Panel1_: TPanel;
    BtnFechar1: TBitBtn;
    procedure dbgLayOutCellClick(Column: TColumn);
    procedure FormActivate(Sender: TObject);
    procedure edtDescricaoKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FazConsulta;
    procedure BtnFechar1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    cod_ban:string;
    { Public declarations }
  end;

var
  frmCon_Layout: TfrmCon_Layout;

implementation

uses dm,clsLayOutchq;

var tq    : TQuery;
    tds   : TdataSource;
    LayOut: TLayOutchq;

{$R *.DFM}

procedure TfrmCon_Layout.dbgLayOutCellClick(Column: TColumn);
begin
  inherited;
 edtdescricao.text:= tq.fieldbyname('descricao').asstring;
 edtdescricao.setfocus;
end;

procedure TfrmCon_Layout.FormActivate(Sender: TObject);
begin
  inherited;
 tq.databasename     := dmint.db.databasename;
 tq.active           := False;
 tds.DataSet         := tq;
 dbgLayOut.DataSource:= tds;
 fazconsulta;
 edtdescricao.setfocus;
end;

procedure TfrmCon_Layout.edtDescricaoKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
 if key=12 then FazConsulta;
end;

procedure TfrmCon_Layout.FazConsulta;
begin
 LayOut.Consultar(tq,edtdescricao.text);
end;

procedure TfrmCon_Layout.BtnFechar1Click(Sender: TObject);
begin
  inherited;
 cod_ban:=tq.fieldbyname('cod_ban').asstring;
 close;
end;

procedure TfrmCon_Layout.FormCreate(Sender: TObject);
begin
 LayOut:= TLayOutchq.Create;
 tds   := TDataSource.create(self);
 tq    := Tquery.create(self);
end;

procedure TfrmCon_Layout.FormDestroy(Sender: TObject);
begin
 LayOut.free;
 tds.free;
 tq.free;
end;

end.
